package com.lovo.pis.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.lovo.pis.dto.PageBean;
import com.lovo.pis.dto.SellOrderBean;
import com.lovo.pis.mapper.SellOrderMapper;
import com.lovo.pis.service.ISellOrderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class SellOrderServiceImpl extends ServiceImpl<SellOrderMapper, SellOrderBean> implements ISellOrderService {

    @Autowired
    SellOrderMapper sellOrderMapper;

    @Override
    public IPage<SellOrderBean> queryAllBuyCarGoods(PageBean<SellOrderBean> pageInfo) {
        QueryWrapper queryWrapper = new QueryWrapper();
        if (pageInfo.getData().getCustomName() != null && pageInfo.getData().getCustomName() != "") {
            queryWrapper.like("custom_name", pageInfo.getData().getCustomName());
        }
        if (pageInfo.getStartDate() != null && pageInfo.getStartDate() != "") {
            queryWrapper.ge("create_time", pageInfo.getStartDate());
        }
        if (pageInfo.getEndDate() != null && pageInfo.getEndDate() != "") {
            queryWrapper.le("create_time", pageInfo.getEndDate());
        }
        return sellOrderMapper.selectPage(new Page<>(pageInfo.getCurPage(), pageInfo.getPageSize()), queryWrapper);
    }

    @Override
    public SellOrderBean queryById(int id) {
        return sellOrderMapper.selectByOrderId(id);
    }

}
